namespace SilverSea.Untilities
{
    using System;
    using System.Diagnostics;

    public class NetworkAdapter
    {
        private long long_0;
        private long long_1;
        private long long_2;
        private long long_3;
        private long long_4;
        private long long_5;
        internal PerformanceCounter performanceCounter_0;
        internal PerformanceCounter performanceCounter_1;
        internal string string_0;

        internal NetworkAdapter(string string_1)
        {
            this.string_0 = string_1;
        }

        public string GetDownloadSpeed()
        {
            string str = string.Empty;
            double downloadSpeedKbps = this.DownloadSpeedKbps;
            if (downloadSpeedKbps < 1000.0)
            {
                return (str + downloadSpeedKbps.ToString("F2") + " kbps");
            }
            downloadSpeedKbps /= 1024.0;
            return (str + downloadSpeedKbps.ToString("F2") + " mbps");
        }

        public string GetUploadSpeed()
        {
            string str = string.Empty;
            double uploadSpeedKbps = this.UploadSpeedKbps;
            if (uploadSpeedKbps < 1000.0)
            {
                return (str + uploadSpeedKbps.ToString("F2") + " kbps");
            }
            uploadSpeedKbps /= 1024.0;
            return (str + uploadSpeedKbps.ToString("F2") + " mbps");
        }

        internal void method_0()
        {
            try
            {
                this.long_4 = this.performanceCounter_0.NextSample().RawValue;
                this.long_5 = this.performanceCounter_1.NextSample().RawValue;
            }
            catch (Exception)
            {
            }
        }

        internal void method_1()
        {
            try
            {
                this.long_2 = this.performanceCounter_0.NextSample().RawValue;
                this.long_3 = this.performanceCounter_1.NextSample().RawValue;
                this.long_0 = this.long_2 - this.long_4;
                this.long_1 = this.long_3 - this.long_5;
                this.long_4 = this.long_2;
                this.long_5 = this.long_3;
            }
            catch (Exception)
            {
            }
        }

        public override string ToString()
        {
            return this.string_0;
        }

        public long DownloadSpeed
        {
            get
            {
                return this.long_0;
            }
        }

        public double DownloadSpeedKbps
        {
            get
            {
                return ((this.long_0 * 8.0) / 1024.0);
            }
        }

        public double DownloadSpeedKBps
        {
            get
            {
                return (((double) this.long_0) / 1024.0);
            }
        }

        public string Name
        {
            get
            {
                return this.string_0;
            }
        }

        public long UploadSpeed
        {
            get
            {
                return this.long_1;
            }
        }

        public double UploadSpeedKbps
        {
            get
            {
                return ((this.long_1 * 8.0) / 1024.0);
            }
        }

        public double UploadSpeedKBps
        {
            get
            {
                return (((double) this.long_1) / 1024.0);
            }
        }
    }
}

